/**
* 
* ====================================================================
*
* @author apov <apov@ymail.com>
*/ 
#pragma once

#include "DBStatement.h"
#include "ODBC_DBSession.h"
#include "ODBC_DBResultSet.h"
#include <LumpData.h>
#include <string>

class ODBC_DBResultSet;
/**
* @class ODBC_DBStatement
*  - 
*/ 
class ODBC_DBStatement : public DBStatement{
	enum{
		DEF_DATA_BUF_SIZE=		9000,
		DEF_MAX_BIND=			100,
	};

public:
	virtual int executeUpdate();
	virtual DBResultSet* executeQuery();
	virtual int prepare( int result_type );
	virtual void reset();	
	virtual DBSession* getSession(){ return session_; }

	virtual void setByte( char& value, short flag );
	virtual void set2Byte( short& value, short flag );	
	virtual void set4Byte( int& value, short flag );	
	virtual void set4Byte( unsigned int& value, short flag );	
	virtual void set8Byte( __int64& value, short flag );	
	virtual void setFloat( float& value, short flag );
	virtual void setString( char* value, short flag, int size = 0 );	
	virtual void setDate( char* value, short flag );
	virtual void setMemory( char* value, int size, short flag );
	virtual void setNull();
	virtual void setReal( double& value, int precision, int scale, short flag );
	virtual int is_procedure();

	ODBC_DBStatement( ODBC_DBSession* session );
	virtual ~ODBC_DBStatement();	

protected:

private:
	int execute( bool result = true );
	void addBindInfo(unsigned int size, short flag, char* data, \
		short fcType, short sqlType);	

	ODBC_DBResultSet* result_set_;
	unsigned int current_bind_pos_;	
	SQLLEN cbParm_;
};
